<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>FileTools | Inner Core 0.1 文档</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic">
  <link rel="stylesheet" href="assets/style.css">
  <link rel="stylesheet" href="assets/sh.css">
  <link rel="canonical" href="https://nodejs.org/api/FileTools.html">
</head>
<body class="alt apidoc" id="api-section-FileTools">
  <div id="content" class="clearfix">
    <div id="column2" class="interior">
      <div id="intro" class="interior">
        <a href="/" title="返回首页">
          Inner Core
        </a>
      </div>
      <ul>
<li><a class="nav-http-www-w3school-com-cn-js-pro_js_syntax-asp" href="http://www.w3school.com.cn/js/pro_js_syntax.asp">W3CSchool - ECMAScript教程</a></li>
<li><a class="nav-http-es6-ruanyifeng-com-README" href="http://es6.ruanyifeng.com/#README">阮一峰 - ECMAScript教程</a></li>
</ul>
<div class="line"></div>

<ul>
<li><a class="nav-Globals" href="Globals.html">Globals - 一般全局函数</a></li>
<li><a class="nav-FileTools active" href="FileTools.html">Files - 文件系统</a></li>
<li><p><a class="nav-Debug" href="Debug.html">Debug - 调试</a></p>
</li>
<li><p><a class="nav-https-developer-mozilla-org-zh-CN-docs-Mozilla-Projects-Rhino-Scripting_Java" href="https://developer.mozilla.org/zh-CN/docs/Mozilla/Projects/Rhino/Scripting_Java">Work with Java - 调用Java API</a></p>
</li>
</ul>
<div class="line"></div>

<ul>
<li><a class="nav-https-gitee-com-dazeyoooo-ICore-Docs" href="https://gitee.com/dazeyoooo/ICore-Docs">Gitee项目 &amp; Issue提交</a></li>
</ul>

    </div>

    <div id="column1" data-id="FileTools" class="interior">
      <header>
        <h1>Inner Core 0.1 文档</h1>
        <div id="gtoc">
          <p>
            <a href="index.html" name="toc">索引</a> |
            <a href="all.html">查看全部</a>
          </p>
        </div>
        <hr>
      </header>

      <div id="toc">
        <h2>目录</h2>
        <ul>
<li><span class="stability_2"><a href="#filetools_filetools">FileTools</a></span><ul>
<li><span class="stability_undefined"><a href="#filetools_filetools_mkdir_path">FileTools.mkdir(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_isexists_path">FileTools.isExists(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_writetext_path_text_append">FileTools.WriteText(path, text[, append])</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readtext_path">FileTools.ReadText(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_writeimage_path_bitmap">FileTools.WriteImage(path, bitmap)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readimage_path">FileTools.ReadImage(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readtextasset_path">FileTools.ReadTextAsset(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readimageasset_path">FileTools.ReadImageAsset(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readbytesasset_path">FileTools.ReadBytesAsset(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_getlistofdirs_path">FileTools.GetListOfDirs(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_getlistoffiles_path_suffix">FileTools.GetListOfFiles(path,suffix)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readkeyvaluefile_path">FileTools.ReadKeyValueFile(path, 分隔符)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_writekeyvaluefile_path_json">FileTools.WriteKeyValueFile(path, json, 分隔符)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_readjson_path">FileTools.ReadJSON(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_writejson_path_json">FileTools.WriteJSON(path, json, 是否格式化)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_mkworkdirs">FileTools.mkworkdirs()</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_getfullpath_path">FileTools.getFullPath(path)</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_mntdir">FileTools.mntdir</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_root">FileTools.root</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_workdir">FileTools.workdir</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_moddir">FileTools.moddir</a></span></li>
<li><span class="stability_undefined"><a href="#filetools_filetools_modpedir">FileTools.modpedir</a></span></li>
</ul>
</li>
</ul>

      </div>

      <div id="apicontent">
        <h1>FileTools<span><a class="mark" href="#filetools_filetools" id="filetools_filetools">#</a></span></h1>
<div class="api_stability api_stability_2"><a href="documentation.html#documentation_stability_index">Stability: 2</a> - FileTools模块主要提供了一些数据读写的方式</div><h2>FileTools.mkdir(path)<span><a class="mark" href="#filetools_filetools_mkdir_path" id="filetools_filetools_mkdir_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
</ul>
</div><p>创建文件夹</p>
<h2>FileTools.isExists(path)<span><a class="mark" href="#filetools_filetools_isexists_path" id="filetools_filetools_isexists_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li>返回 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a></li>
</ul>
</div><p>判断文件是否存在</p>
<h2>FileTools.WriteText(path, text[, append])<span><a class="mark" href="#filetools_filetools_writetext_path_text_append" id="filetools_filetools_writetext_path_text_append">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><code>text</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 写入的文本</li>
<li><p><code>append</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type">&lt;boolean&gt;</a> 是否追加文本</p>
</li>
<li><p>写入文本</p>
</li>
</ul>
</div><h2>FileTools.ReadText(path)<span><a class="mark" href="#filetools_filetools_readtext_path" id="filetools_filetools_readtext_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li>返回 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></li>
</ul>
</div><p>读取文件所有内容并返回。如果文件不存在，则为null。</p>
<h2>FileTools.WriteImage(path, bitmap)<span><a class="mark" href="#filetools_filetools_writeimage_path_bitmap" id="filetools_filetools_writeimage_path_bitmap">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><p><code>bitmap</code> <span class="type">&lt;android.graphics.Bitmap&gt;</span> Bitmap对象</p>
</li>
<li><p>写出图片</p>
</li>
</ul>
</div><h2>FileTools.ReadImage(path)<span><a class="mark" href="#filetools_filetools_readimage_path" id="filetools_filetools_readimage_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><p>返回 <span class="type">&lt;android.graphics.Bitmap&gt;</span></p>
</li>
<li><p>读取图片 Bitmap</p>
</li>
</ul>
</div><h2>FileTools.ReadTextAsset(path)<span><a class="mark" href="#filetools_filetools_readtextasset_path" id="filetools_filetools_readtextasset_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><p>返回 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a></p>
</li>
<li><p>读取材质包内文本</p>
<h2>FileTools.ReadImageAsset(path)<span><a class="mark" href="#filetools_filetools_readimageasset_path" id="filetools_filetools_readimageasset_path">#</a></span></h2>
</li>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><p>返回 <span class="type">&lt;android.graphics.Bitmap&gt;</span></p>
</li>
<li><p>读取材质包内图片 Bitmap</p>
</li>
</ul>
</div><h2>FileTools.ReadBytesAsset(path)<span><a class="mark" href="#filetools_filetools_readbytesasset_path" id="filetools_filetools_readbytesasset_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><p>返回 <span class="type">&lt;Byte[]&gt;</span> </p>
</li>
<li><p>读取材质包内文件 Bytes</p>
</li>
</ul>
</div><h2>FileTools.GetListOfDirs(path)<span><a class="mark" href="#filetools_filetools_getlistofdirs_path" id="filetools_filetools_getlistofdirs_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 文件夹路径</li>
<li><p>返回 <span class="type">&lt;File[]&gt;</span></p>
</li>
<li><p>获取文件夹内的文件夹 []</p>
</li>
</ul>
</div><h2>FileTools.GetListOfFiles(path,suffix)<span><a class="mark" href="#filetools_filetools_getlistoffiles_path_suffix" id="filetools_filetools_getlistoffiles_path_suffix">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 文件夹路径</li>
<li><code>suffix</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 文件后缀</li>
<li><p>返回 <span class="type">&lt;File[]&gt;</span></p>
</li>
<li><p>获取文件夹内为该后缀的文件 []</p>
</li>
</ul>
</div><h2>FileTools.ReadKeyValueFile(path, 分隔符)<span><a class="mark" href="#filetools_filetools_readkeyvaluefile_path" id="filetools_filetools_readkeyvaluefile_path">#</a></span></h2>
<div class="signature"><ul>
<li><p><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</p>
</li>
<li><p>读取键值对文件 {}</p>
</li>
</ul>
</div><h2>FileTools.WriteKeyValueFile(path, json, 分隔符)<span><a class="mark" href="#filetools_filetools_writekeyvaluefile_path_json" id="filetools_filetools_writekeyvaluefile_path_json">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
<li><p><code>json</code> <span class="type">&lt;object&gt;</span></p>
</li>
<li><p>写出键值对文件</p>
</li>
</ul>
</div><h2>FileTools.ReadJSON(path)<span><a class="mark" href="#filetools_filetools_readjson_path" id="filetools_filetools_readjson_path">#</a></span></h2>
<div class="signature"><ul>
<li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</li>
</ul>
</div><ul>
<li>读取json文件 {}</li>
</ul>
<h2>FileTools.WriteJSON(path, json, 是否格式化)<span><a class="mark" href="#filetools_filetools_writejson_path_json" id="filetools_filetools_writejson_path_json">#</a></span></h2>
<div class="signature"><ul>
<li><p><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</p>
</li>
<li><p>写出json文件 </p>
</li>
</ul>
</div><h2>FileTools.mkworkdirs()<span><a class="mark" href="#filetools_filetools_mkworkdirs" id="filetools_filetools_mkworkdirs">#</a></span></h2>
<div class="signature"><ul>
<li>创建预设文件夹</li>
</ul>
</div><h2>FileTools.getFullPath(path)<span><a class="mark" href="#filetools_filetools_getfullpath_path" id="filetools_filetools_getfullpath_path">#</a></span></h2>
<div class="signature"><ul>
<li><p><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string&gt;</a> 路径</p>
</li>
<li><p>文件路径补全</p>
</li>
</ul>
</div><p>路径常量</p>
<h2>FileTools.mntdir<span><a class="mark" href="#filetools_filetools_mntdir" id="filetools_filetools_mntdir">#</a></span></h2>
<div class="signature"><ul>
<li>&quot;/mnt&quot;</li>
</ul>
</div><h2>FileTools.root<span><a class="mark" href="#filetools_filetools_root" id="filetools_filetools_root">#</a></span></h2>
<div class="signature"><ul>
<li>&quot;/storage/emulated/0/&quot;</li>
</ul>
</div><h2>FileTools.workdir<span><a class="mark" href="#filetools_filetools_workdir" id="filetools_filetools_workdir">#</a></span></h2>
<div class="signature"><ul>
<li>&quot;games/com.mojang/coreengine/&quot;</li>
</ul>
</div><h2>FileTools.moddir<span><a class="mark" href="#filetools_filetools_moddir" id="filetools_filetools_moddir">#</a></span></h2>
<div class="signature"><ul>
<li>&quot;games/com.mojang/mods/&quot;</li>
</ul>
</div><h2>FileTools.modpedir<span><a class="mark" href="#filetools_filetools_modpedir" id="filetools_filetools_modpedir">#</a></span></h2>
<div class="signature"><ul>
<li>&quot;games/com.mojang/modpe/&quot;</li>
</ul>
</div>
      </div>
    </div>
  </div>
  <script src="assets/sh_main.js"></script>
  <script src="assets/sh_javascript.min.js"></script>
  <script>highlight(undefined, undefined, 'pre');</script>
  <!-- __TRACKING__ -->
</body>
</html>